<script>
//调用微信JS api 支付
function jsApiCall() {
	WeixinJSBridge.invoke('getBrandWCPayRequest', {$jsApiParameters}, function (res) {
		WeixinJSBridge.log(res.err_msg);
		if (res.err_msg == 'get_brand_wcpay_request:ok') {
            window.location.href = "{:url('pay_ok', ['order_id' => $order_id])}"
		} else {
            $.toptip(res.err_msg, 'error');
			$('#loadingToast').hide();
		}
	});
}

function callpay() {
	if (typeof(WeixinJSBridge) == "undefined") {
		if (document.addEventListener) {
			document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		} else if (document.attachEvent) {
			document.attachEvent('WeixinJSBridgeReady', jsApiCall);
			document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		}
	} else {
		jsApiCall();
	}
}
</script>
